Stack CreateStack( int MaxSize ){
	Stack S;
	S=(Stack)malloc(sizeof(struct SNode));
	S->Data=(ElementType *)malloc(sizeof(ElementType)*MaxSize);
	S->MaxSize=MaxSize;
	S->Top1=-1;
	S->Top2=MaxSize;
	return S;
}
bool Push( Stack S, ElementType X, int Tag ){
	if(S->Top1+1==S->Top2) {
			printf("Stack Full\n");
			return false;
	}
	if(Tag==1) {
		S->Top1++;
		S->Data[S->Top1]=X;
		return true;
	}
	else if(Tag==2){
		S->Top2--;
		S->Data[S->Top2]=X;
		return true;
	}
	return false;
}
ElementType Pop( Stack S, int Tag ){
	if(Tag==1){
		if(S->Top1==-1) {
			printf("Stack %d Empty\n", Tag);
			return ERROR; 
		}
		S->Top1--;
		return S->Data[S->Top1+1];
	}
	else if(Tag==2){
		if(S->Top2==S->MaxSize){
			printf("Stack %d Empty\n", Tag);
			return ERROR;
		}
		S->Top2++;
		return S->Data[S->Top2-1];
	}
	return ERROR;
}
